<?php
/*
教师管理模块
*/
include_once('include/top.php');

$action=fs_get_value("do");
switch($action)
{
	case	"addmember"	     : addmember()	         ; break;
        case	"addteacher"	     : addteacher()	         ; break;
	case	"add"	         : do_addmember()	     ; break;
	case	"delete"	     : delete_member()	     ; break;
	case    "searchmember"   : searchmember()        ; break;
	case    "batchadd"       : batchadd()            ; break;         //批量添加
	case    "do_batchadd"    : do_batchadd()         ; break;
	default				     : main()		         ; break;
}
?>
<script type="text/javascript">
 function getOptionMAJOR(){
  $.getJSON("option.php",{'bval':$("#departid").val()},function(data){
    $("#majorid").empty();//每次选择前，清空小类的值。
    $("#classid").empty();
    $("#classid").html("<option value='-1'>请选择班级</option>");
    $("#majorid").html("<option value='-1'>请选择专业</option>");
    $.each(data, function(index,array){
     var option="<option value='"+array['id']+"' >"+array['name']+"</option>"; 
     $("#majorid").append(option);
    });                
   }); 
 }
 $(document).ready(function(){
    $("#departid").change(function(){
        getOptionMAJOR();
    });
 });
</script>

<?php

function main()
{
    global $db;
	$member_name = fs_get_value("member_name");
	$username = fs_get_value("username");
	$tel = fs_get_value("tel");
	$email = fs_get_value("email");
	$money = fs_get_value("money");
	$payed = fs_get_value("payed");
	$state = fs_get_value("state");
	$logintimes = fs_get_value("logintimes");
	$lastlogintime = fs_get_value("lastlogintime");
	$onlinetime = fs_get_value("onlinetime");
	$registerdate = fs_get_value("registerdate");
	$conditionarray = array($member_name,$username,$tel,$email,$money,$payed,$state,$logintimes,$lastlogintime,$olinetime,$registerdate);
	$valuearray = array(" and realname like '%".$member_name."%'"," and passport like '%".$username."%'"," and tel like '%".$tel."%'"," and email like '%".$email."%'"," and money = ".$money," and payed = ".$payed," and state = ".$state," and logintimes = ".$logintimes," and lastlogintime like '%".$lastlogintime."%'"," and onlinetime = ".$onlinetime," and registerdate = ".strtotime($registerdate));
	$sql = "select * from nettteach_member where type = '2'";
	for($i=0;$i<count($conditionarray);$i++ ){
		if($conditionarray[$i] == ''){
			$valuearray[$i] = '';
		}
		$sql.=$valuearray[$i];
	}
        $departid = fs_get_value("departid");
        $majorid = fs_get_value("majorid");
        if($departid != '-1' && $departid != '')
        {
             $sql.= "  and departmentid = '".$departid."'";   
        }
        if($majorid != '-1' && $majorid != '')
        {
             $sql.= "  and majorid = '".$majorid."'";   
        }
        $sql.="  order by departmentid,majorid,star";
	$member_result = $db -> query($sql);
	$recordcount = $db -> num_rows($member_result);
	@$page=$_GET['p'];
	if ($page==null){$page=1;}
	$pagesize=15;								//每页显示数
	$pagecount=ceil($recordcount/$pagesize);	//计算总页
	if ($page>$pagecount){$page=$pagecount;}
	if ($page<1){$page=1;}
?>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
  <tr>
    <th class="CTitle">教师管理</th>
  </tr>
  <tr>
    <td class="CPanel">
    <div class="SubMenu">
		<a href="admin_teacher.php?">教师管理</a> | 
		<a href="admin_teacher.php?do=addteacher">添加教师</a> | 
		<a href="admin_teacher.php?do=searchmember">搜索教师</a>|
        <a href="admin_teacher.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">教师登陆记录</a>-->
	</div>
	
	<form action="?do=delete" method="post" name="fooeeform" style="margin:0px">
		<table border="0" cellpadding="0" cellspacing="0"  class="TablePanel" width="100%">
			<tr align="center" class="TDHead">
				<td nowrap><input type=button style="font-size:9pt;width:50px;" value="全选" onclick="click_allid(fooeeform,1)"/></td>
				<td nowrap><input type=button style="font-size:9pt;width:60px;" value="全取消" onclick="click_allid(fooeeform,0)"/></td>
				<td nowrap><input type="submit" style="font-size:9pt;width:50px;" value="删除" onclick="return delid()"/></td>

				<td nowrap width="500"><input type=button style="font-size:9pt;width:80px;" onclick="window.location.href('admin_teacher.php?do=searchmember')" value="搜索教师" />
				</td>
				<td nowrap>.</td>
				<td nowrap>.</td>
				<td width="30%" nowrap></td>
				<td nowrap></td>
			</tr>
		</table>
<div id="click_idall">
    <div align="left" style="padding:5px;">
      <table border="0" cellpadding="0" cellspacing="0" class="TablePanel" align="center" width="100%">
        <tr align="center">
		  <td class="TDHead">√</td>
          <td class="TDHead" nowrap>用户名</td>
          <td class="TDHead" nowrap>教师姓名</td>
          <td class="TDHead" nowrap>所属系/专业</td>
          <td class="TDHead" nowrap>教师类型</td>
          <td class="TDHead" nowrap>联系电话</td>
          <td class="TDHead" nowrap>电子邮箱</td>
		  <td class="TDHead" nowrap>教师状态</td>
          <td class="TDHead" nowrap>最后登陆时间</td>
          <td class="TDHead" nowrap>操 作</td>
        <!--  <td class="TDHead" nowrap>登陆记录</td>-->
        </tr>
<?php
	$member_result=$db->query($sql." limit ".($page-1)*($pagesize).",$pagesize");
	while($member_row = $db->fetch_array($member_result))
	{
?>
		<tr id="t<?php echo($member_row["id"]);?>" onclick="click_tr('<?php echo ($member_row["id"]);?>')" onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='FFFFFF'" title=单击选中 align="center">
			<td height="27"><input name='id[]' type='checkbox' id="c<?php echo($member_row["id"]);?>" value='<?php echo ($member_row["id"]);?>' onclick="click_tr('<?php echo ($member_row["id"]);?>')"></td>
			<td><?php echo($member_row['passport']);?></td>
            <td><a href="?do=addmember&member_id=<?php echo ($member_row["id"]);?>"><?php echo($member_row["realname"]);?></a></td>
            <td><?php echo(fs_get_departname($member_row['departmentid']).'/'.fs_get_majorname($member_row['majorid']));?></td>
            <td><?php echo fs_get_star($member_row['star']);?></td>
			<td><?php echo($member_row['tel']);?></td>
			<td><?php echo($member_row['email']);?></td>
			<td><?php echo(fs_get_member_state($member_row['state']));?></td>
			<td><?php if($member_row['lastlogintime'] !=''){echo(date('Y-m-d H:i:s',$member_row['lastlogintime']));}else{echo "暂无登陆记录";}?></td>
			<td><a href="?do=addmember&member_id=<?php echo ($member_row["id"]);?>">编缉</a></td>
			<!--<td><a href="admin_teacher_record.php?member_id=<?php echo ($member_row["id"]);?>">查看登陆记录</a></td>-->
		</tr>
		<tr>
			<td height=1 colspan=10 bgcolor="#E8F1FF" onMouseOver="bgColor='#FF8899'" onMouseOut="bgColor='E7sxE7sxE7sx'"></td>
		</tr>
<?php
	}
?>
	</table>
	</div>
	</div>
	</form>
	
	
	
	<center>
<?php
/*分页示例:

pager(传入URL , 数据总数 , 开始条数 , 每页数目)
*/
echo(pager('?p={page}',$recordcount,($page-1)*($pagesize),$pagesize));		
?>
                
</center>
	</td>
	</tr>
	</table>

<?php
}
function fs_get_departname($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".TABLE_DEPARTMENT." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}

//根据专业ID返回专业名称 20120817qzr
function fs_get_majorname($i)
{
	if ( $i=='' || is_null($i) || !is_numeric($i))	{return '无';break;}
	global $db;
	$sql	=	"select name from ".TABLE_MAJOR." where id=$i ";
	$result =	$db -> query($sql);
	$row	=	$db -> fetch_array($result);
	return	$row['name'];
}
?>


<!--
编缉教师开始
-->
<?php
function addmember()
{
    global $db;
	$member_id = fs_get_value("member_id");
	if($member_id != ''){
		$sql = "select * from nettteach_member where id = ".$member_id;
		$member_result = $db -> query($sql);
		$member_row = $db -> fetch_array($member_result);
	}
?>
<script src="./js/Main.js"></script>
<script type="text/javascript">
window.onload = function()
{
        CKEDITOR.replace( 'introduce',{ height : '150px', width:'600px',toolbar:'MyToolbar',fontSize_sizes:'16/16px' } );
};
</script>
<script type="text/javascript">
function getUsername(str){
    if (str.length==0){ 
		document.getElementById("user_info").innerHTML="* 不能为空！";
		return false;
	}
    var url="ajax/getparts.php?u="+str;
	url=url+"&sid="+<?php echo $member_id?>;
    $.ajax({
         url: url,
         cache: false,
         dataType: "html",
         success:function(html){
			　 $("#user_info").html(html);
			  }
    });
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">教师管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="admin_teacher.php?">教师管理</a> | 
		<a href="admin_teacher.php?do=addteacher">添加教师</a> | 
		<a href="admin_teacher.php?do=searchmember">搜索教师</a>|
        <a href="admin_teacher.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">教师登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
                           
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="?do=add&member_id=<?php echo($member_id);?>">
			<fieldset>
				<legend>编缉教师</legend>
                带<span style="color:#FF0000;">*</span>的必填。<br/><br/>
                    <label>用户名：</label><input name="username" type="text"  class="text" value="<?php echo($member_row['passport']);?>" onblur="getUsername(this.value)" ><span id="user_info" style="color:#FF0000;">*只能输入4~30个字母或数字</span><br/><br/>
					<label>教师密码：</label><input name="password" type="text"  class="text" value=""><span style="color:#FF0000;">不修改勿填</span><br/><br/>
                    <label>教师姓名：</label><input name="member_name" type="text"  class="text" value="<?php echo($member_row['realname']);?>" /><span style="color:#FF0000;">*</span><br/><br/>
                    <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;" >
                                        <option value="-1">请选择系</option>
                                        <?php
                                        $sql="select* from nettteach_department where 1=1";
                                        $result=mysql_query($sql);
                                        //循环列出选项
                                                while($rows=mysql_fetch_array($result))
                                        {?>
                                                <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$member_row['departmentid'])echo 'selected'; ?>><?php echo $rows['name'];?></option>
                                        <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                        <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                             <option value="-1">请选择专业</option>
                                        <?php
                                        $sql="select* from nettteach_major where departmentid=".$member_row['departmentid'];
                                        $result=mysql_query($sql);
                                        //循环列出选项
                                                while($rows=mysql_fetch_array($result))
                                        {?>
                                        <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$member_row['majorid'])echo 'selected'; ?>><?php echo $rows['name'];?></option>
                                        <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    
                    <label>名师类型：</label>
					<select name="star" style="width:300px;">
<!--					    <option value="" <?php if($member_row['star'] == null){echo("selected");}?>>未知</option>-->
					    <option value="0" <?php if($member_row['star'] == 0){echo("selected");}?>>普通教师</option>
					    <option value="1" <?php if($member_row['star'] == 1){echo("selected");}?>>国家级名师</option>
                        <option value="2" <?php if($member_row['star'] == 2){echo("selected");}?>>省级名师</option>
                        <option value="3" <?php if($member_row['star'] == 3){echo("selected");}?>>校级名师</option>
					</select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>教师状态：</label>
                    <select name="state" style="width:300px;">
					    <option value="0" <?php if($member_row['state'] == 0){echo("selected");}?>>未激活</option>
					    <option value="1" <?php if($member_row['state'] == 1){echo("selected");}?>>已激活</option>
					</select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>联系电话：</label><input name="tel" type="text"  class="text" value="<?php echo($member_row['tel']);?>"><br/><br/>
					<label>电子邮件：</label><input name="email" type="text"  class="text" value="<?php echo($member_row['email']);?>"><br/><br/>
                    <label>登陆次数：</label><input name="logintimes" type="text"  class="text" value="<?php echo($member_row['logintimes']);?>"><br/><br/>
					<input type="hidden" name="lastphoto" value="<?php echo($member_row['photo']);?>" style="width:300px;" />
                    <label>头像上传：</label><input type="hidden" name="photo" value="<?php echo($member_row['photo']);?>" style="width:300px;" /><br /><br />
					<label></label><iframe frameborder="0" name="upload_frame" scrolling="no" src="admin_upload.php" width="280" onload="this.height=this.contentWindow.document.body.scrollHeight"></iframe><br />
                    <label></label><span>只能上传小于5M的图片，格式仅限于jpg,gif,png,bmp,jpeg。</span><br/><br/>
                    <label>名师简介：</label><div style="padding-left:100px"><textarea name="introduce"><?php echo($member_row['introduce']);?></textarea></div><br/><br/>
                    <div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return Check();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="admin_teacher.php">返回列表</a></div>
                                 
                                        </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
function do_addmember(){
    global $db;
	$member_name = fs_get_value("member_name");
	$username = fs_get_value("username");
	$password = fs_get_value("password");
	$tel = fs_get_value("tel");
	$email = fs_get_value("email");
	$majorid = fs_get_value("majorid");
	$departid = fs_get_value("departid");
	$state = fs_get_value("state");
	$logintimes = fs_get_value("logintimes");
	$registerdate = strtotime(fs_get_value("registerdate"));
	$star = fs_get_value("star");
    $photo = fs_get_value("photo");
    $introduce = fs_get_value("introduce");
        $lastphoto = fs_get_value("lastphoto"); //原头像地址 若换了则删除原文件
                //添加教师
                if(fs_get_value("member_id") == ''){
                        if($username != '' && $member_name != ''){
                                $num = $db -> row_count(TABLE_MEMBER,"passport = '".$username."'");
                                if($num>0)
                                {
                                        fs_showmsg("该用户名已存在！");
                                        exit();
                                }else
                                {
                                        $sql = "insert into nettteach_member (passport,realname,type,star) value ('".$username."','".$member_name."','2','".$star."')";
                                        $db->query($sql);
                                        $id = mysql_insert_id();
                                }
                        }
                }
                else{
                        //修改教师
                        $id = fs_get_value("member_id");
                        if($username != '' && $member_name != ''){
                                $sql = "update nettteach_member  set passport = '".$username."',realname = '".$member_name."',star='".$star."' where id = ".$id;
                                $db -> query($sql);
                        }
                }
                if($id == '')
                {
                       fs_showmsg("添加错误！");
                       exit();  
                }
                if($password != ''){
                        $sql = "update nettteach_member  set password = '".fs_sha1($password)."' where id = ".$id;
                        $db -> query($sql);
                }
                if($photo != '' && $photo !=$lastphoto){
                    $sql = "update nettteach_member set photo = '".$photo."' where id = ".$id;
                    $db -> query($sql);
                    $file=$lastphoto; 
                    if (unlink($file)) {
//                       echo "The file was deleted successfully.", "n";
                    } else {
//                       echo "The specified file could not be deleted. Please try again.", "n";
                    }
                }
                if($introduce != ''){
                        $sql = "update nettteach_member set introduce = '".$introduce."' where id = ".$id;
                        $db -> query($sql);
                }
//                if($tel != ''){
                        $sql = "update nettteach_member set tel = '".$tel."' where id = ".$id;
                        $db -> query($sql);
//                }
//                if($email != ''){
                        $sql = "update nettteach_member set email = '".$email."' where id = ".$id;
                        $db -> query($sql);
//                }
                if($majorid != '-1' && $majorid != ''){
                        $sql = "update nettteach_member set majorid = ".$majorid." where id = ".$id;
                        $db -> query($sql);
                }
                if($departid != '-1'){
                        $sql = "update nettteach_member set departmentid = ".$departid." where id = ".$id;
                        $db -> query($sql);
                }
                if($state != ''){
                        $sql = "update nettteach_member set state = ".$state." where id = ".$id;
                        $db -> query($sql);
                }
                else{
                        $sql = "update nettteach_member set state = null where id = ".$id;
                        $db -> query($sql);
                }
                if($logintimes != ''){
                        $sql = "update nettteach_member set logintimes = ".$logintimes." where id = ".$id;
                        $db -> query($sql);
                }
                if($registerdate != ''){
                        $sql = "update nettteach_member set registerdate = ".$registerdate." where id = ".$id;
                        $db -> query($sql);
                }
                if(fs_get_value("member_id") == ''){
                        fs_showmsg("添加成功！","?do=main");
                }
                else{
                        fs_showmsg("修改成功！");
                }
        
}
?>
<!--
编缉教师结束
-->
<!--
添加教师开始
-->
<?php
function addteacher()
{
    global $db;
?>
<script type="text/javascript">
window.onload = function()
{
        CKEDITOR.replace( 'introduce',{ height : '150px', width:'600px',toolbar:'MyToolbar',fontSize_sizes:'16/16px' } );
};
function getUsername(str){
    if (str.length==0){ 
		document.getElementById("user_info").innerHTML="* 不能为空！";
		return false;
	}
    var url="ajax/getparts.php?u="+str;
	url=url+"&sid=";
    $.ajax({
         url: url,
         cache: false,
         dataType: "html",
         success:function(html){
			　 $("#user_info").html(html);
			  }
    });
}
</script>
<script src="./js/Main.js"></script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">教师管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="admin_teacher.php?">教师管理</a> | 
		<a href="admin_teacher.php?do=addteacher">添加教师</a> | 
		<a href="admin_teacher.php?do=searchmember">搜索教师</a>|
        <a href="admin_teacher.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">教师登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="?do=add&member_id=<?php echo($member_id);?>">
			<fieldset>
                           
				<legend>添加教师</legend>
				    带<span style="color:#FF0000;">*</span>的必填。<br/><br/>
					<label>用户名：</label><input name="username" type="text"  class="text" onblur="getUsername(this.value)" ><span id="user_info" style="color:#FF0000;">*只能输入4~30个字母或数字</span><br/><br/>
					<label>登陆密码：</label><input name="password" type="text"  class="text" value="123456"><span style="color:#FF0000;">*密码为4至20位</span><br/><br/>
                    <label>教师姓名：</label><input name="member_name" type="text"  class="text" value="<?php echo($member_row['realname']);?>" /><span style="color:#FF0000;">*</span><br/><br/>
                    <label> 院系：</label><select name="departid" id="departid" style="width:300px;">
                                 <option value="-1">请选择系</option>
                                    <?php
                                    $sql="select* from nettteach_department where 1=1";
                                    $result=mysql_query($sql);
                                    //循环列出选项
                                            while($rows=mysql_fetch_array($result))
                                    {?>
                                            <option value=<?php echo $rows['id']; ?>><?php echo $rows['name'];?></option>
                                    <?php } ?>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                        <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>名师类型：</label>
                        <select name="star" style="width:300px;">
                            <option value="0" >普通教师</option>
                            <option value="1" >国家级名师</option>
                            <option value="2">省级名师</option>
                            <option value="3">校级名师</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/> 
                    <label>教师状态：</label>
                        <select name="state" style="width:300px;">
                            <option value="0" >未激活</option>
                            <option value="1" selected>已激活</option>
                        </select><span style="color:#FF0000;">*</span><br/><br/>
                    <label>联系电话：</label><input name="tel" type="text"  class="text" value="<?php echo($member_row['tel']);?>"><br/><br/>
					<label>电子邮件：</label><input name="email" type="text"  class="text" value="<?php echo($member_row['email']);?>"><br/><br/>
					<label>头像上传：</label><input type="hidden" name="photo" value="<?php echo($member_row['photo']);?>" style="width:300px;" /><br /><br />
					<label></label><iframe frameborder="0" name="upload_frame" scrolling="no" src="admin_upload.php" width="280" onload="this.height=this.contentWindow.document.body.scrollHeight"></iframe><br />
                    <label></label><span style="color:#FF0000;">*</span><span>只能上传小于5M的图片，格式仅限于jpg,gif,png,bmp,jpeg。</span><br/><br/>
                    <label>名师简介：</label><div style="padding-left:100px"><textarea name="introduce"><?php echo($member_row['introduce']);?></textarea></div><br/><br/>
					<input name="registerdate" type="hidden"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}else{echo date("Y-m-d",$member_row['registerdate']);}?>"> 		
					<div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return Check();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="admin_teacher.php">返回列表</a></div>
                                 
                                        </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>
<!--
添加教师结束
-->
<?php
function searchmember()
{
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">教师管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="admin_teacher.php?">教师管理</a> | 
		<a href="admin_teacher.php?do=addteacher">添加教师</a> | 
		<a href="admin_teacher.php?do=searchmember">搜索教师</a>|
        <a href="admin_teacher.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">教师登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list">
			<form name="searchform" method="post" action="?">
			<fieldset>
				<legend>搜索教师</legend><br><br>
					<label><div align="right">教师姓名：</div></label><input name="member_name" type="text"  class="text" value="" /><br/><br/>
					<label><div align="right">用户名：</div></label><input name="username" type="text"  class="text" value=""><br/><br/>
					<!--<label><div align="right">联系电话：</div></label><input name="tel" type="text" style="width:400px;" class="text" value=""><br/>-->
					<label><div align="right">电子邮件：</div></label><input name="email" type="text"  class="text" value=""><br/><br/>
                                 <label><div align="right">院系：</div></label><select name="departid" id="departid" style="width:300px;">
                                 <option value="-1">请选择系</option>
                                    <?php
                                    $sql="select* from nettteach_department where 1=1";
                                    $result=mysql_query($sql);
                                    //循环列出选项
                                            while($rows=mysql_fetch_array($result))
                                    {?>
                                            <option value=<?php echo $rows['id']; ?>><?php echo $rows['name'];?></option>
                                    <?php } ?>
                        </select><br/><br/>
                        <label><div align="right">专业：</div></label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><br/><br/>		
					<div class="submit">
					<label></label><input type="submit" value="确认搜索"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="admin_teacher.php">返回列表</a></div>
			</fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>

<?php
//删除教师
function delete_member()
{
    global $db;
	$i=0;
	$member_id = $_POST['id'];
        if($member_id != ''){
                while($member_id){
                    if($member_id[$i]==null) break;
                        $sql = "delete from nettteach_member where id = ".$member_id[$i]."";
                    $db -> query($sql);
                    $i++;
                }
                fs_showmsg('删除成功!');
        }else{
                fs_showmsg('请选择要删除的教师!');
        }
}
?>
<?php
//批量导入
function batchadd()
{
    global $db;
?>
<script type="text/javascript">
function checkupload(){
        if(document.addform.departid.value ==  "-1"){
       alert("请选择系!");
       return false;
    }
    if(document.addform.departid.value !=  "" &&document.addform.departid.value !=  "-1"){
           var majorid = document.addform.majorid.value;
           if(majorid =="-1"){
                   alert("请选择专业!");
                   return false;
           }
    }
    if(document.addform.file.value ==  "-1"){
       alert("请导入文件!");
       return false;
    }
}
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		<tr>
		    <th class="CTitle">教师管理</th>
		</tr>	
		<tr>
			<td class="CPanel">
    <div class="SubMenu">
		<a href="admin_teacher.php?">教师管理</a> | 
		<a href="admin_teacher.php?do=addteacher">添加教师</a> | 
		<a href="admin_teacher.php?do=searchmember">搜索教师</a>|
        <a href="admin_teacher.php?do=batchadd">批量导入</a>
		<!--<a href="admin_teacher_record.php">教师登陆记录</a>-->
	</div>
			</td>
		</tr>	
		<tr>
			<td>
			<div class="middle_right_list" style="font-size:13px;">
			<form name="addform" method="post" action="teacheruploadexcel.php" enctype="multipart/form-data">
			<fieldset>
                <legend>批量添加教师</legend><br>
                    <label>批量导入： </label><input type="hidden" name="leadExcel" value="true">   
                    <input type="file" name="file">  支持.xls文件,两列(用户名,姓名),从第二行开始录入<br/><br/>
                    <label>院系：</label>
                        <select name="departid" id="departid" style="width:300px;">
                                <option value="-1">请选择系</option>
                                <?php 
                                    $sql ="select * from nettteach_department where 1=1";
                                    $result = $db ->query($sql);
                                    while($row = $db->fetch_array($result)){
                                ?>
                                    <option value="<?php echo $row['id']?>"><?php echo $row['name']?></option>
                                <?php }?>
                        </select><br/><br/>
                    <label>专业：</label>
                        <select name="majorid" id="majorid" style="width:300px;">
                                <option value="-1">请选择专业</option>
                        </select><br/><br/>
					<label>登陆密码：</label><input name="password" type="text"  class="text" value="123456"><br/><br/>
                    <label>教师状态：</label>
                        <select name="state" style="width:300px;">
                            <option value="0" >未激活</option>
                            <option value="1" selected>已激活</option>
                        </select><br/><br/><input name="registerdate" type="hidden"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}?>">
					<label>注册时间：</label><input name="date" type="text"  class="text" value="<?php if($member_id == ''){echo(date("Y-m-d",time()));}?>"><br/><br/>		
					<div class="submit">
					<label></label><input type="hidden" name="test_major" value="1" /><input type="submit" class="sub" value="确认提交" onclick="return checkupload();"/>&nbsp;&nbsp;&nbsp;&nbsp;<a class="lj" href="admin_teacher.php">返回列表</a></div>
                 </fieldset>
			</form>
			</div>
			</td>
		</tr>
	</table>
<?php
}
?>